package exsun.jt808.data;

import exsun.jt808.data.base.StatusResult;
import exsun.jt808.data.distribute_data.DistributeEntity;
import exsun.jt808.data.distribute_data.jt808.CallBack;
import exsun.jt808.data.enume.OrderSendStatus;
import exsun.jt808.data.jt809_data.monitor.slave.DownCtrlMsgMonitorVehicleReq;
import exsun.jt808.data.util.GsonUtils;
import exsun.jt808.data.util.HttpUtil;
import org.apache.catalina.util.URLEncoder;

import java.nio.charset.Charset;

public class MainTest {
    public static void main(String[] args) {

        CallBack send = new CallBack(1, "123");
        send.devNo = "123";
        send.response = true;
        StatusResult clientRsp = postOrder("http://127.0.0.1:8089", send, 3000);

    }

    public static StatusResult postOrder(String httpRequestUrl, DistributeEntity entity, int timeout){
        URLEncoder encoder = new URLEncoder();
        String str = HttpUtil.sendPost(httpRequestUrl + "/KafkaApi/distributeInner?distributeContent="
                        + encoder.encode(GsonUtils.getJsonFromObject(entity), Charset.defaultCharset()),"",
                3000,3000,"UTF-8");
        StatusResult result = GsonUtils.getObjectFromJson(str, StatusResult.class);
        return result;
    }
}



